package utils;

import java.io.PrintWriter;
import java.io.StringWriter;

public class ExceptionUtils {
    /**
     * 获取异常详细信息
     */
    public static String getExceptionMsg(Exception e){

        String msg = null;

        try {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw,true);

            e.printStackTrace(pw);
            pw.flush();
            sw.flush();
            msg = sw.toString();
            pw.close();
            sw.close();
        }catch (Exception error){
            error.printStackTrace();
        }

        return msg;
    }
}
